
<!DOCTYPE html>
<html class="no-js">
<head lang="en">

    <#include "../head_import.html" />

</head>
<body>
<#include "../include/top_nav.html">
    <div class="am-cf admin-main">

        <!-- sidebar start -->
        <#include "../order/left.html">
            <!-- sidebar end -->



<script type="text/javascript">
$(function() {
	$("#baseForm").validate();
});
function changeCount(){
	var totalWeight=0.0;
	$("#[id^='itemCount_']").each(function(){
		var ss=parseFloat(jQuery(this).val());
		var h=jQuery(this).attr("id");
		var index=h.split("_")[1];
		var weight=$("#itemWeight_"+index).html();
		totalWeight+=ss*weight;
	});
	ajaxtotalDeliveryFee($("#shippingId").val(),totalWeight);
	setTimeout(function(){changePrice()},1000);
}

function changePrice(){
	var totalPrice=0.0;
	$("#[id^='itemPrice_']").each(function(){
		var ss=parseFloat(jQuery(this).val());
		var h=jQuery(this).attr("id");
		var index=h.split("_")[1];
		var count=$("#itemCount_"+index).val();
		$("#subtotal_"+index).html("");
		$("#subtotal_"+index).html(count*ss);
		totalPrice+=count*ss;
	});
	$("#productPrice").html("");
	$("#productPrice").html(totalPrice);
	$("#total").html("");
	$("#total").html(parseFloat($("#freight").val())+totalPrice);
	$("#totalPice").val(parseFloat($("#freight").val())+totalPrice);
}

function changeFreight(){
	var ss=parseFloat($("#productPrice").html());
	$("#total").html("");
	ss+=parseFloat($("#freight").val());
	$("#total").html(ss);
	$("#totalPice").val(ss);
}




function ajaxtotalDeliveryFee(d,w){
	$.post("../order/ajaxtotalDeliveryFee.do", {
		'deliveryMethod':d,
		'weight':w
	}, function(data) {
		if(data.status==1){
			$("#freight").val(data.freight);
			return data.freight;
		}
	},'json');
}
</script>
<style type="text/css">
.addr{padding:2px 0;}
.title{font-size:14px;}
</style>
 <div class="admin-content">
<div class="body-box">
<div class="rhead">
	<div class="rpos"><@s.m "global.position"/>:  <@s.m "order.function"/> - <@s.m "global.edit"/></div>
	<form class="ropt">
		<input type="button" value="<@s.m "global.backToList"/>" onclick="history.back();"/>
	</form>
	<div class="clear"></div>
</div>
<@p.form id="baseForm" action="o_update.do" labelWidth="12">
<@p.td colspan="2"><strong class="title"><@s.m "order.product"/></strong></@p.td><@p.tr/>
<@p.td colspan="2">
<@p.table value=order.items;item,i,has_next><#rt/>
	<@p.column code="product.code" style="width:100px"><#if item.product.productExt??>${item.product.productExt.code!}</#if></@p.column><#t/>
	<@p.column code="product.name" align="left"><img src="${item.product.productExt.coverImg!}" width="50" height="50"/>
	${item.product.name!}&nbsp;<#if item.productFash??>${item.productFash.attitude!}</#if></@p.column><#t/>
	<@p.column code="orderItem.finalPrice" style="width:110px">
	 <#if item.productFash??><input type="text" id="itemPrice_${item.id}" name="itemPrice" value="${item.salePrice!}" onchange="changePrice();" style="width:100px"/>
	 <#else><input type="text" id="itemPrice_${item.id}" name="itemPrice" value="${item.salePrice!}"  onchange="changePrice();"  style="width:100px"/>
	 </#if></@p.column><#t/>
	 <@p.column code="单重" style="width:60px"><span id="itemWeight_${item.id}">${item.product.weight}</span></@p.column><#t/>
	<@p.column code="orderItem.count" style="width:60px">
		<input type="hidden" name="itemId" value="${item.id}"/>
		<input type="text" id="itemCount_${item.id}" name="itemCount" value="${item.count}" onchange="changeCount();" style="width:50px"/>
	</@p.column><#t/>
	<@p.column code="orderItem.subtotal" style="width:100px"><span id="subtotal_${item.id}"><#if item.productFash??>${item.productFash.salePrice*item.count!0}
	 <#else>${item.product.salePrice*item.count!0}</#if></span>
	</@p.column><#t/>
</@p.table>
</@p.td><@p.tr/>

<@p.td colspan="2"><strong class="title"><@s.m "order.info"/></strong></@p.td><@p.tr/>
<@p.td colspan="1" width="50" label="订单编号">${order.code}</@p.td>
<@p.td colspan="1" width="50" label="order.createTime">${order.createTime}</@p.td><@p.tr/>

<@p.td colspan="1" width="50" label="order.status">
<@s.m "order.status.${order.status}"/>
</@p.td>
<@p.td colspan="1" width="50" label="order.paymentStatus">
<@s.m "order.paymentStatus.${order.paymentStatus}"/>
</@p.td>
<@p.tr/>
<@p.td colspan="1" width="50" label="order.shippingStatus">
<@s.m "order.shippingStatus.${order.shippingStatus}"/>
</@p.td>
<@p.select colspan="1" width="50" label="order.shipping" id="shippingId" name="shippingId" value=order.shipping.id  onchange="changeCount();" list=shippingList listKey="id" listValue="name"/>
<@p.tr/>

<@p.td colspan="1" width="50" label="order.productPrice"><span id="productPrice">${order.productPrice}</span></@p.td>
<@p.td colspan="1" width="50" label="order.freight" required="true">
<input type="text" id="freight" name="freight" value="${order.freight}" class="required number" onchange="changeFreight();" style="width:70px;" maxlength="20"/>
 &nbsp; <@s.m "order.weight"/>: <span id="weight">${order.weight}</span> g
</@p.td><@p.tr/>
<@p.td colspan="1" width="50" label="order.total"><span id="total">${order.total!0}</span>
<input type="hidden" id="totalPrice" name="totalPrice" value="${order.total!0}"/></@p.td>
<@p.select colspan="1" width="50" label="order.payment"  name="paymentId" value=order.payment.id list=paymentList listKey="id" listValue="name"/>
<@p.tr/>

<@p.td colspan="2"><strong class="title">收货人信息</strong></@p.td><@p.tr/>
<@p.td colspan="1" width="50" label="收货人姓名">${order.receiveName!}</@p.td>
<@p.td colspan="1" width="50" label="收货人电话">${order.receiveMobile!}</@p.td><@p.tr/>
<@p.td colspan="1" width="50" label="收货人固定电话">${order.receivePhone!}</@p.td>
<@p.td colspan="1" width="50" label="收货人邮编">${order.receiveZip!}</@p.td><@p.tr/>
<@p.td colspan="2" label="收货人地址">${order.receiveAddress!}</@p.td><@p.tr/>
<@p.textarea colspan="2" label="order.comments" name="comments" value=order.comments cols="70" rows="3"/><@p.tr/>
<@p.td colspan="2">
	<@p.hidden name="id" value=order.id/>
	<@p.submit code="global.submit"/> &nbsp; <@p.reset code="global.reset"/>
</@p.td>
</@p.form>
</div>
</body>
</html>